package com.etone.smartAudit.domain;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.etone.smartAudit.enums.StateType;
import com.etone.smartAudit.vo.FileVO;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.util.StringUtils;

import java.util.Date;

/**
 * @author: 蒋学伟
 * @create: 2020-07-08 14:33:03
 * @Description ToolCase
 */
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Data
@TableName(value = "f_tool_case")
public class ToolCase {

    @TableId(type = IdType.AUTO, value = "intId")
    private Integer id;

    /**
     * 案例名称
     */
    @TableField("vcName")
    private String name;

    /**
     * 下载次数
     */
    @TableField("intDownloadCnt")
    private Integer downloadCnt;

    /**
     * 文件信息
     */
    @TableField("vcFiles")
    private String files;

    /**
     * 图片
     */
    @TableField("vcCover")
    private String cover;

    /**
     * 备注｜简介
     */
    @TableField("vcRemark")
    private String remark;

    /**
     * 创建时间
     */
    @TableField("dtCreateTime")
    private Date createTime;

    /**
     * 创建人id
     */
    @TableField("intCreateAdminId")
    private Integer createAdminId;

    /**
     * 创建人名称
     */
    @TableField("vcCreateAdminNickName")
    private String createAdminNickName;

    /**
     * 有效性
     */
    @TableField("vcState")
    private StateType state;

    /**
     * 工具id
     */
    @TableField("intToolId")
    private Integer toolId;

    /**
     * 工具名称
     */
    @TableField("vcToolName")
    private String toolName;

    public FileVO getCoverFileVO() {
        if (!StringUtils.isEmpty(cover)) {
            return JSON.parseObject(cover, FileVO.class);
        }
        return null;
    }
}
